<script src="__PUBLIC__/ganged/Js/city-picker.data.js"></script>
<script src="__PUBLIC__/ganged/Js/city-picker.js"></script>
<script src="__PUBLIC__/ganged/Js/main.js"></script>
<!-- css -->
<link href="__PUBLIC__/ganged/Css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/ganged/Css/city-picker.css" rel="stylesheet" type="text/css" />

<link href="__PUBLIC__/admin/datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/datetimepicker/bootstrap-datetimepicker.min.js" ></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/datetimepicker/bootstrap-datetimepicker.zh-CN.js" ></script>

<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js" ></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css"> 
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/upload.js" ></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/My97DatePicker/calendar.js" ></script>
<!-- 定位 -->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=yWnFso0oyjmX79HzCx1DRz2sBtvweQfI"></script>
<style>
.bg{ background: none; border: none;}
.uploadify-button-text{ display: inline-flex; }
.uploadify-button-text button{ margin: -10px; }
.upviewer img{ height:90px; width: 120px; }
.upviewer ul{ margin:0px; padding:0px; }
.upviewer li{ margin:0px; padding:0px; position: relative; display:inline-block; width:120px; height:90px; background-position: center; background-size: contain; background-repeat: no-repeat; float: left; margin-right:10px; border:1px #ccc solid; background-color:#f0f0f0;}
.upviewer li a{ display:inline-block; position: absolute; bottom:0px; left:0px; text-align:center; width:100%; background-color:rgba(0,0,0,0.3); color:red; cursor: pointer; }
.upviewer li:hover a{ background-color:rgba(0,0,0,0.8); }
</style>
<div class="container" style="padding-top: 50px;">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<form class="form-horizontal" role="form" id="post_form" action="{:U('edit')}">
				<div class="form-group">
                     <label for="title" class="col-sm-2 control-label">经销商名称:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="shop_name" id="shop_name" value="{$info.shop_name}" />
                    </div>
                </div>
                <div class="form-group">
                     <label for="title" class="col-sm-2 control-label">品牌名称:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="brand_name" id="brand_name" value="{$info.brand_name}" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="title" class="col-sm-2 control-label">姓名:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="name" id="name" value="{$info.name}" />
                    </div>
                </div>
                <div class="form-group">
                     <label for="title" class="col-sm-2 control-label">联系电话:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="mobile" id="mobile" value="{$info.mobile}" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="instructions" class="col-sm-2 control-label">须知:</label>
                    <div class="col-sm-5" >
                    <textarea class="form-control" name="instructions" id="instructions" rows="10">{$info.instructions}</textarea>
                    </div>
                </div>
                <!-- 省市三级联动 -->
                    <div class="form-group">
                    <label for="ds" class="col-sm-2 control-label">省市区:<span style="color: red;">*</span></label>
                    <div id="distpicker" style="margin-left:20%">
                        <div class="form-group">
                            <div style="position: relative;">
                                <input id="city-picker3" class="form-control" readonly type="text" value="{$info.province}/{$info.city}/{$info.district}" data-toggle="city-picker" style="width:400px;">
                            </div>
                        </div>
                        <div class="form-group">
                            <button class="btn btn-warning" id="reset" type="button">重置</button>
                            <button class="btn btn-danger" id="destroy" type="button">确定</button>
                        </div>
                    </div>
                    </div>
                <!-- 三级联动结束 -->

                <div class="form-group">
                    <label for="address" class="col-sm-2 control-label">详细地址:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="address" id="address" value="{$info.address}"/>
                    </div>
                </div>   
                <div class="form-group">
                    <label for="lng" class="col-sm-2 control-label">经度:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="lng" id="lng" value="{$info.lng}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="lat" class="col-sm-2 control-label">纬度:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="lat" id="lat" value="{$info.lat}"/>
                    </div>
                </div>             
                <div class="form-group">
                    <label for="picture" class="col-sm-2 control-label">列表图片(300x80):<span style="color: red;">*</span></label>
                    <div class="col-sm-10 js_upload_img">
                        <input type="file" class="form-control" id="picture" value="{$info.picture}"><br /> 
                        <div name="picture" class="upviewer">
                            <ul>
                                <notempty name="info['picture']">
                                    <li>
                                        <input type="hidden" name="picture[]" value="{$info.picture}">
                                        <img src="{$info.picture}"/><a d_path="{$info.picture}">删除</a>
                                    </li>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>              
                <div class="form-group">
                    <label for="desc_img" class="col-sm-2 control-label">经销商介绍(640x100):<span style="color: red;">*</span></label>
                    <div class="col-sm-10 js_upload_img">
                        <input type="file" class="form-control" id="desc_img" value="{$info.desc_img}"><br /> 
                        <div name="desc_img" class="upviewer">
                            <ul>
                                <notempty name="info['desc_img']">
                                    <li>
                                        <input type="hidden" name="desc_img[]" value="{$info.desc_img}">
                                        <img src="{$info.desc_img}"/><a d_path="{$info.desc_img}">删除</a>
                                    </li>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="pictures" class="col-sm-2 control-label">轮播(640x260):<span style="color: red;">*</span></label>
                    <div class="col-sm-10 js_upload_imgs">
                        <input type="file" class="form-control" id="pictures"><br /> 
                        <div name="pictures" class="upviewer">
                            <ul>
                                <notempty name="info['pictures']">
                                    <php>
                                        $info['pictures'] = explode(',', $info['pictures']) ;
                                    </php>
                                    <volist name="info['pictures']" id="img">
                                        <li>
                                            <input type="hidden" name="pictures[]" value="{$img}">
                                            <img src="{$img}"/><a d_path="{$img}">删除</a>
                                        </li>
                                    </volist>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="boss_img" class="col-sm-2 control-label">老板照片:</label>
                    <div class="col-sm-10 js_upload_imgs">
                        <input type="file" class="form-control" id="boss_img"><br /> 
                        <div name="boss_img" class="upviewer">
                            <ul>
                                <notempty name="info['boss_img']">
                                    <php>
                                        $info['boss_img'] = explode(',', $info['boss_img']) ;
                                    </php>
                                    <volist name="info['boss_img']" id="img">
                                        <li>
                                            <input type="hidden" name="boss_img[]" value="{$img}">
                                            <img src="{$img}"/><a d_path="{$img}">删除</a>
                                        </li>
                                    </volist>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="business_license" class="col-sm-2 control-label">营业执照:</label>
                    <div class="col-sm-10 js_upload_imgs">
                        <input type="file" class="form-control" id="business_license"><br /> 
                        <div name="business_license" class="upviewer">
                            <ul>
                                <notempty name="info['business_license']">
                                    <php>
                                        $info['business_license'] = explode(',', $info['business_license']) ;
                                    </php>
                                    <volist name="info['business_license']" id="img">
                                        <li>
                                            <input type="hidden" name="business_license[]" value="{$img}">
                                            <img src="{$img}"/><a d_path="{$img}">删除</a>
                                        </li>
                                    </volist>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                     <label for="ds" class="col-sm-2 control-label">所属管理员:</label>
                    <div class="col-sm-2">
                        <select name="admin_id" class="form-control"> 
                            <option value="0">请选择管理员</option>
                            <volist name="admin_arr" id="vo">
                                <option value="{$key}" <if condition="$info['admin_id'] eq $key">selected</if> >{$vo}</option>
                            </volist>
                        </select>
                    </div>
                </div>                
                <div class="form-group">
                    <label class="col-sm-2 control-label">1小时送达:</label>
                    <div class="col-sm-10">
                        <label for="is_auth1" class="control-label">
                            <input type="radio" id="is_auth1" name="is_auth" value="0" <if condition="$info['is_auth'] neq 1">checked</if>>否
                        </label>
                        <label for="is_auth2" class="control-label">
                            <input type="radio" id="is_auth2" name="is_auth" value="1"  <if condition="$info['is_auth'] eq 1">checked</if>>是
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">管长:</label>
                    <div class="col-sm-10">
                        <label for="is_gz1" class="control-label">
                            <input type="radio" id="is_gz1" name="is_gz" value="0" <if condition="$info['is_gz'] neq 1">checked</if>>否
                        </label>
                        <label for="is_gz2" class="control-label">
                            <input type="radio" id="is_gz2" name="is_gz" value="1"  <if condition="$info['is_gz'] eq 1">checked</if>>是
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">采集会员:</label>
                    <div class="col-sm-10">
                        <label for="member_grade1" class="control-label">
                            <input type="radio" id="member_grade1" name="member_grade" value="0" <if condition="$info['member_grade'] eq 0">checked</if>>否
                        </label>
                        <label for="member_grade2" class="control-label">
                            <input type="radio" id="is_status2" name="member_grade" value="1"  <if condition="$info['member_grade'] eq 1">checked</if>>普通会员
                        </label>
                        <label for="member_grade2" class="control-label">
                            <input type="radio" id="is_status2" name="member_grade" value="2"  <if condition="$info['member_grade'] eq 2">checked</if>>Vip会员
                        </label>
                    </div>
                </div>
                <div class="form-group">
                     <label for="title" class="col-sm-2 control-label">采集会员到期时间:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control form_datetime" value="{:date('Y-m-d H:i', $info['member_expire'])}" name="member_expire" id="member_expire"/>
                    </div>
                </div>
				<div class="form-group">
					<label class="col-sm-2 control-label">状态:</label>
					<div class="col-sm-10">
						<label for="is_status1" class="control-label">
							<input type="radio" id="is_status1" name="status" value="0" <if condition="$info['status'] neq 1">checked</if>>关闭
						</label>
						<label for="is_status2" class="control-label">
							<input type="radio" id="is_status2" name="status" value="1"  <if condition="$info['status'] eq 1">checked</if>>开启
						</label>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						 <input type="hidden" name="id" value="{$info.id}">
						<button type="button" class="btn btn-primary" id="btn" lng="0" lat="0">提交</button>
					</div>
				</div>
			</form>
		</div>
</div>
<script>
function getPlace(addr, callback) {
    var myGeo = new BMap.Geocoder();
    var lng = 0;
    var lat = 0;
    myGeo.getPoint(addr, function(point) {
        if(point) {
            lng = point.lng;
            lat = point.lat;
        }
        console.log(addr, {'lat':lat, 'lng':lng}, point);
        callback({'lat':lat, 'lng':lng})
    });
}	
$(function(){	

    $(".form_datetime").datetimepicker({format: 'yyyy-mm-dd hh:ii', 'language':'zh-CN'});

	// $('#member_expire').on('click',function(){
 //        new Calendar({id:'#member_expire',
 //            class:'amd',//这里填写class；给我们星期天修改样式
 //        })
 //    });
    
	$("#btn").click(function(){
        // 省市区
        var pcd = $("#city-picker3").val();
        var $form = $("#post_form");
        var $data = {};
        var $form_data = $form.serializeArray();
        $.each($form_data, function(k, v){
            $data[v['name']] = v['value'];
        })
        $data['pcd'] = pcd;
        
        var submit = function(point){
            if(typeof(point['lat']) != 'undefined'){
                $data['lat'] = point['lat'];
            }
            if(typeof(point['lng']) != 'undefined'){
                $data['lng'] = point['lng'];
            }
            
            $.post($form.attr('action'), $data, function(obj){
                alert(obj.m);
                if(obj.s){
                    if(typeof(obj.url)!= "undefined" && obj.url){
                        location.href = obj.url;
                    }
                }
            })
        }
        // address = pcd.split("/").join("")+$data['address'];
        // if(address){
        //     // 获取经纬
        //     getPlace(address, submit);
        // }else{
            submit({});
        // }
	})
});
</script>
